<?php
header("Content-type: text/html; charset=utf-8");
ini_set('display_errors',1);
set_time_limit(0); 
include_once dirname(dirname(__FILE__)).'/mgtv_init.php';

include_once dirname(dirname(__FILE__)) .'/models/queue_task_model.php';

$queue_task_model = new queue_task_model();	

$db = nn_get_db(NL_DB_WRITE);
$sql = "select * from nns_vod where nns_deleted!=1 and nns_category_id='10000001'  limit 31,30";
$list = nl_db_get_all($sql, $db);
//
//
foreach ($list as $key => $value) {
	echo $value['nns_name']."<br>";
	
	$sql_index = "select * from nns_vod_index where nns_deleted!=1 and nns_vod_id='{$value['nns_id']}'";
	$list_index = nl_db_get_all($sql_index, $db);
	foreach ($list_index as $key => $value_index) {
		echo $value_index['nns_name']."<br>";
		
		$sql_media = "select * from nns_vod_media where nns_deleted!=1 and nns_vod_id='{$value['nns_id']}' and nns_vod_index_id='{$value_index['nns_id']}' order by nns_kbps desc";
		$list_media = nl_db_get_all($sql_media, $db);
		foreach ($list_media as $key => $value_meida) {
			echo $value_meida['nns_id']."<br>";
			$queue_task_model->q_add_task($value_meida['nns_id'], BK_OP_MEDIA, BK_OP_DELETE,null,$list_media[0]['nns_id']);
		}
	$queue_task_model->q_add_task($value_index['nns_id'], BK_OP_INDEX, BK_OP_DELETE);
	}
	$queue_task_model->q_add_task($value['nns_id'], BK_OP_VIDEO, BK_OP_DELETE);
}
?>